<?php 
namespace app\api\controller\v1;
use app\api\service\Token;
use think\Request;
use think\Controller;
use think\Db;

// 用来验证账号信息

class Base extends Controller {

    protected function _initialize(){
        $token = Request::instance()->header('token');

        $status = Token::verifyToken($token); 
        if(!$status){
            throw new \think\exception\HttpException(401, 'Token已过期或无效Token', null, []);
        }
        // $this->check();
    }

    // 检测是否有token
    protected function check() {
        $token = Request::instance()->header('token');

        $status = Token::verifyToken($token); 
        if(!$status){
            throw new \think\exception\HttpException(401, 'Token已过期或无效Token', null, []);
        }
    }
}